package com.ice.ubt;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.ice.ubt.annotate.BindView;
import com.ice.ubt.ubt.UBT;

public class MainActivity extends AppCompatActivity {

    @BindView(id = R.id.btn, tag = "按钮")
    private Button mBtnButton;
    @BindView(id = R.id.edt, tag = "edt")
    private EditText mEdtEditText;
    @BindView(id = R.id.edt2, tag = "edt2")
    private EditText mEdtEditText2;
    @BindView(id = R.id.tv, tag = "tv")
    private TextView mTvTextView;
    @BindView(id = R.id.toggle, tag = "开关")
    private ToggleButton mToggleToggleButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        UBT.bind(this);
        Button send = (Button) findViewById(R.id.send);
        send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*UBTDataBean dataBean = new UBTDataBean();
                // TODO: 17/6/15 取数据
//                dataBean.data =
                dataBean.app = "UBT";
                dataBean.extra = "{}";
                dataBean.gps = "{}";
                dataBean.mobile = "13812345678";
                dataBean.token = "";
                API.getUBTServices().postUBTData(dataBean).enqueue(new Callback<Void>() {
                    @Override
                    public void onResponse(Call<Void> call, Response<Void> response) {
                        // TODO: 17/6/14  清空已上传的数据
                        Log.e("TAG", "onResponse: " + "");
                    }

                    @Override
                    public void onFailure(Call<Void> call, Throwable t) {
                        Log.e("TAG", "onFailure: " + t);
                    }
                });*/
                App.getInstance().uploadDataService(MainActivity.this);
//                Log.e("TAG", DbCore.getDaoSession().getUBTEventDao().loadAll().size() + " : " + DbCore.getDaoSession().getUBTEventDao().loadAll());
            }
        });


        /*UserTestDao userTestDao = DbCore.getDaoSession().getUserTestDao();
        UserTest userTest = new UserTest("aaa");
        UserTest userTest2 = new UserTest("bbb");
        if (userTestDao.insertOrReplace(userTest) != -1 ? true : false) {
            List<UserTest> list = userTestDao.queryBuilder().list();
            Log.e("list.......",list.toString());
        } if (userTestDao.insertOrReplace(userTest2) != -1 ? true : false) {
            List<UserTest> list = userTestDao.queryBuilder().list();
            Log.e("list.......",list.toString());
        }*/
    }
}
